package com.jiaai.web.article;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jiaai.article.api.IEssayApi;
import com.jiaai.article.model.IEssay;
import com.jiaai.util.RestResultGenerator;
import org.springframework.web.bind.annotation.*;

/**
 * Created by Administrator on 2018/1/8.
 */
@RestController
@RequestMapping("/api/v1/admin/article")
public class arcitleController {

    @Reference
        private IEssayApi iEssayApi;

    @GetMapping("/all")
    public Object arcitleAll(){
       Object list = iEssayApi.articleAll(1);
        return RestResultGenerator.genSuccessResult(list);
    }

    @PostMapping("/add")
    public Object articleAdd(@RequestBody IEssay iEssay){
        iEssayApi.articleAdd(iEssay);
        return RestResultGenerator.genSuccessResult("添加成功");
    }

    @PostMapping("/delete/{id}")
    public Object delete(@PathVariable Integer id){
        iEssayApi.delete(id);
        return RestResultGenerator.genSuccessResult("删除成功");
    }

    @GetMapping("/allContent/{id}")
    public Object articleContent(@PathVariable Integer id){
        Object list = iEssayApi.articleContent(id);
        return RestResultGenerator.genSuccessResult(list);
    }
}
